﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Toolbox"
                    xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">
    <Style TargetType="{x:Type local:ToolboxCategory}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolboxCategory}">
                    <Grid Background="Transparent">
                        <theme:ClassicBorderDecorator x:Name="PART_SelectedItem"
                                                  BorderStyle="Raised"
                                                  Background="{TemplateBinding Background}"
                                                  BorderThickness="3"
                                                  BorderBrush="{TemplateBinding BorderBrush}"
                                                  SnapsToDevicePixels="true" Margin="2">
                            <Grid>
                                <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding MainItem}" />
                                <Canvas Name="ExpanderCanvas" Visibility="Collapsed">
                                    <Path Width="5.57359" Height="8.70267" Canvas.Right="2" Canvas.Bottom="2" Stretch="Fill" Fill="#FF5E5E5E" Data="F1 M 44.1443,39.0107L 38.5707,34.6594L 38.5707,43.362L 44.1443,39.0107 Z "/>
                                </Canvas>
                            </Grid>
                        </theme:ClassicBorderDecorator>
                        <Popup x:Name="Popup" Placement="Right" IsOpen="{TemplateBinding IsExpanded}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade" HorizontalOffset="-2">
                            <Border Name="SubmenuBorder" SnapsToDevicePixels="True" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Padding="2,0,0,0">
                                <StackPanel Orientation="Horizontal" IsItemsHost="True" />
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
                        </Trigger>
                        <Trigger Property="IsExpanderVisible" Value="True">
                            <Setter TargetName="ExpanderCanvas" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsPressed"
                                 Value="true">
                            <Setter Property="BorderStyle"
                                    Value="RaisedPressed"
                                    TargetName="PART_SelectedItem"/>
                        </Trigger>
                        <Trigger Property="IsEnabled"
                                 Value="false">
                            <Setter Property="Foreground"
                                    Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderBrush" Value="{x:Static theme:ClassicBorderDecorator.ClassicBorderBrush}"/>
        <Setter Property="BorderThickness" Value="3"/>
        <Setter Property="Width" Value="45" />
        <Setter Property="Height" Value="45" />
    </Style>

    <Style TargetType="{x:Type local:ToolboxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolboxItem}">
                    <theme:ClassicBorderDecorator x:Name="ContentContainer"
                                                  BorderStyle="Raised"
                                                  Background="{TemplateBinding Background}"
                                                  BorderThickness="3"
                                                  BorderBrush="{TemplateBinding BorderBrush}"
                                                  SnapsToDevicePixels="true">
                        <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </theme:ClassicBorderDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                            <Setter Property="BorderStyle" Value="RaisedFocused" TargetName="ContentContainer"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="BorderStyle" Value="RaisedPressed" TargetName="ContentContainer"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background"
                Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
        <Setter Property="Foreground"
                Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="BorderBrush"
                Value="{x:Static theme:ClassicBorderDecorator.ClassicBorderBrush}"/>
        <Setter Property="BorderThickness"
                Value="3"/>
        <Setter Property="Width" Value="40" />
        <Setter Property="Height" Value="40" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="Margin" Value="2" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>